﻿using Common;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ResponseManager
{
	GameRoot gameRoot;
	public ResponseManager(GameRoot gameRoot) {
		this.gameRoot = gameRoot;
	}
	Dictionary<ActionCode, BaseRequest> dicRequest = new Dictionary<ActionCode, BaseRequest>();

	public void OnInit() {

	}

	public void AddRequest(ActionCode actionCode, BaseRequest baseRequest) {
		dicRequest.Add(actionCode, baseRequest);
	}
	public void RemoveRequest(ActionCode actionCode) {
		dicRequest.Remove(actionCode);
	}
	public void HandleAction(ActionCode actionCode, string data) {
		BaseRequest baseRequest;
		bool b = dicRequest.TryGetValue(actionCode, out baseRequest);
		// Debug.Log();
		if (!b) {
			Debug.LogWarning("对应的请求类不存在" + actionCode);
			return;
		}
		baseRequest.AddRequest(data);
	}



}
